package com.avsdk;

import java.nio.ByteBuffer;




import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.PixelFormat;
import android.graphics.Bitmap.Config;
import android.os.Message;
import android.util.Log;
import android.view.SurfaceView;

public class AudioPlay {
	private Thread playAudioThread;

	audioRecordPlay audio = null;


	private Runnable playAudioProc = new Runnable() {
		public void run() {

			audio.OnPlay() ;
		}
	};


	

	public void StartPlay()
	{

		audio=new audioRecordPlay();




		playAudioThread = new Thread(playAudioProc);
		playAudioThread.start();			

		
	}
	
	public void WritePlayBuffer(byte[] playbuffer, int len)
	{
		if(audio != null)
		{
			audio.AddPlayBuffer(playbuffer,len);
		}
	}
	
	
	public void StopPlay()
	{

		audio.isPlaying=false;
		while(audio.capfinish == false)
		{
			try {
				Thread.sleep(30);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}	

		
	}
	
}
